package com.b2b2c.store.single.controller;


import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.b2b2c.store.single.entity.Brand;
import com.b2b2c.store.single.logic.BrandLogic;
import com.b2b2c.store.single.service.IBrandService;
import com.b2b2c.until.AjaxMap;
import com.b2b2c.until.IsLogin;

/**
  *   商品分类控制器
 * @author Administrator
 */
@RestController
public class BrandController 
{
	@Autowired
	private HttpServletRequest req;
	
	
	@Resource
	private RedisTemplate<String, List<Brand>> redisTemplate;
	
	/**
	  *   商品分类 
	 * @return
	 */
	@RequestMapping("Brand/getBrandList")
	public Map<String, ?> classList() {
		
		if (!IsLogin.checkLogin(this.req)) {
			
			return AjaxMap.getInstance("未登录").notLoggedIn();
		}
		
		IBrandService<Brand> brandLogic = new BrandLogic(req);
		
		List<Brand> classList = brandLogic.getBrandList(redisTemplate);
		
		return AjaxMap.getInstance(classList).getAjaxResultByMap();
		
	}
}
